<!DOCTYPE html>
<html  lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>
        资源
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/css/x-admin.css}" media="all">

</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>资源列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">


    <xblock><button class="layui-btn" onclick="member_add('添加资源','/touser/addResource','550','400')"><i class="layui-icon">&#xe608;</i>添加</button><span class="x-right" style="line-height:40px">总 [[${pageInfo.total } ]]条记录</span></xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>资源ID</th>
            <th>资源名称</th>
            <th>资源描述</th>
            <th>资源URL</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="x-link">
        <tr  th:each="Bar_list:${pageInfo.list}">
            <td class="center" th:text="${Bar_list.id}" ></td>
            <td class="center" th:text="${Bar_list.barListName}"></td>
            <td class="center">
                <span class="center">[[${Bar_list.description}]]</span>
            </td>
            <td class="center" th:text="${Bar_list.url}" ></td>
            <td class="center">
                <a class="layui-btn layui-btn-warm" href="">
                    <i class="layui-icon">&#xe642;</i>
                    Edit
                </a>
                <a class="layui-btn layui-btn-danger" href="javascript:;" onclick="commemt_del(this,$(this).parents('tr').find('td')[0].innerHTML)" >
                    <i class="layui-icon">&#xe640;</i>
                    Delete
                </a>
            </td>
        </tr>
        </tbody>
    </table>

    <div id="page"></div>
</div>

<!--=====================================javascript================================= -->
<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/js/x-layui.js}" charset="utf-8"></script>



<script   type="text/javascript" th:inline="javascript" >
    layui.use(['element','laypage','layer','form'], function(){
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        laydate = layui.laydate;//日期插件
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层
        form = layui.form();//弹出层

        //  1)分页插件

        laypage({
            cont: 'page' // 所在模块的ID
            ,pages: [[${pageInfo.pages }]]
            ,curr: [[${pageInfo.pageNum }]]
            ,first: '首页'
            ,last: '尾页'
            ,prev: '<em><</em>'
            ,next: '<em>></em>'
            ,jump : function(obj, first){
                if (!first) {
                    var pn=obj.curr;
                    window.location.href="/touser/tosetresource_admin?pn="+pn;//跳转链接
                }
            }
        });

    })

    //==================================================================================//
    /* 添加新用户（初始添加不带任何权限） */
    function member_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

    /* 用户添加完成后，通过update更新具体权限 */

    /* 单用户删除模块  */
    function commemt_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.ajax({
                url: '/touser/resource?id=' +id,
                type: 'DELETE',
                async: false,
                success:function(result){
                    console.log(result);
                    if(result.content=="success"){
                        $(obj).parents("tr").remove();
                        location.reload();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('删除失败!',{icon:2,time:1000});
                    }

                }
            });

        });
    }

</script>

</body>
</html>